package com.rachel.studyapp;

import android.content.Context;

import com.franmontiel.persistentcookiejar.PersistentCookieJar;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
import com.rachel.okhttplib.OkHttpCommonClient;

import org.litepal.LitePalApplication;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * Created by zhengshaorui on 2017/8/11.
 */

public class StudyApplication extends LitePalApplication {

    public static Context mContext;
    private static final int TIME_OUT = 20;
    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        //初始化okhttp
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .readTimeout(TIME_OUT, TimeUnit.SECONDS)
                .connectTimeout(TIME_OUT, TimeUnit.SECONDS)
                .writeTimeout(TIME_OUT+TIME_OUT,TimeUnit.SECONDS)
                .cookieJar(new PersistentCookieJar(new SetCookieCache(),new SharedPrefsCookiePersistor(this)))
                .build();

        OkHttpCommonClient.getInstance().setOkhttpClient(okHttpClient);



    }
    public static Context getContext(){
        return  mContext;
    }
}
